var sending = false;

$(document).ready(function(){

    $(".common_errors_container").css({'width': (($(".form_container_center").outerWidth() - 2) + "px")});

    var validateParams = {
        rules:
        {
            first_name: "required",
            last_name: "required",
            email: {
                required: true,
                email: true
            }
        },

        messages:
        {
            first_name: "<strong>First Name: </strong>Please enter your first name",
            last_name:  "<strong>Last Name: </strong>Please enter your last name",
            email:      "<strong>Email: </strong>Please enter existing e-mail address"
        },
        submitHandler: function(form) {
            form.submit();
        }
    };

    var feedbackFormValidatorSettings = generateSettings( validateParams );

    $('#download_form').submit(function(){
        $(this).unbind()
               .validate( feedbackFormValidatorSettings );
        return $(this).valid();
    });

    $("#button_send").bind("click", function(){
        sending = true;
    });

    var url = $("#download_url").val();
    var trackingKeyword = $("#downloadTrackingKeyword").val();
    var productCode = $("#downloadProductCode").val();
    var productVersion = $("#downloadProductVersion").val();

    if (trackingKeyword && productCode && productVersion)
    {
        _gaq.push(['_trackPageview', trackingKeyword]);
        Stats.trackEvent('Download', productCode, productVersion );
        setTimeout(function() { console.log('123'); window.location = url; }, 2000);
    }
});